package com.lagou.dao.mapper;

import com.lagou.dao.pojo.AuthCode;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface AuthCodeMapper {

    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "email", column = "email"),
            @Result(property = "code", column = "code"),
            @Result(property = "createtime", column = "createtime", javaType = Date.class),
            @Result(property = "expiretime", column = "expiretime", javaType = Date.class)
    })
    @Select("select * from lagou_auth_code where email = #{0} and code = #{1}")
    public List<AuthCode> findUserCode(String email, String code);

    @Insert("insert into lagou_auth_code (email, code, createtime, expiretime) values (#{email}, #{code}, #{createtime}, #{expiretime})")
    public int insertAuthCode(AuthCode authCode);
}
